<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@ include file="/WEB-INF/jsp/common/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>菜单管理</title>
<jsp:include page="../addlink.jsp" />
<meta charset="utf-8" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" type="text/css"	href="${pageContext.request.contextPath}/statics/css/common.min.css">
<link rel="stylesheet" type="text/css"	href="${pageContext.request.contextPath}/statics/css/system_list.css">
<link rel="stylesheet" type="text/css"	href="${pageContext.request.contextPath}/statics/lib/treeTable/themes/vsStyle/treeTable.min.css">
<script type="text/javascript"	src="${pageContext.request.contextPath}/statics/lib/treeTable/jquery.treeTable.js"></script>
<style>
.table td:first-child{text-align:left;padding-left:0;}
</style>
<script type="text/javascript">
	$(function() {
		$("#userListTable").treeTable({
			expandLevel : 3
		}).show();
	});

	var deptMgr = {

		delMenu : function(menuId) {
			if (confirm("您确定要删除此菜单吗?")) {
				$.ajax({
					type : 'post',//请求方式
					url : '${pageContext.request.contextPath}/sys/menu/delMenu',
					dataType : 'json', //有几种格式 xml html json text 等常用
					//data传值的另外一种方式 form的序列化
					data : {
						"menuId" : menuId
					},//传递给服务器的参数				
					success : function(data) {//与服务器交互成功调用的回调函数
						if(data.code == 200){
							setTimeout(function(){
								window.location.href = "${pageContext.request.contextPath}/sys/menu/toMenuList"
							},1000);
							zxTips_short({txt:data.message});
						}
					}
				});
			}
		}
	};
</script>
</head>
<body>
	<jsp:include page="../head.jsp" />
	<div class="container-fluid all">
		<jsp:include page="../menu.jsp" />
		<div class="maincontent">
			<ol class="breadcrumb">
				<li class="url-root"><a>系统设置</a></li>
				<li class="url-root"><a>菜单管理</a></li>
				<li class="active">菜单列表</li>
			</ol>
			<div class="control_bar row">
				<div class="control_left">
					<a class="btn btn-default"
						href="${basePath}/sys/menu/toMenuEdit?editFlag=1" role="button">添加</a>
				</div>
			</div>
			<div class="mode">
				<table class="table table-hover" id="userListTable">
					<thead>
						<tr>
							<th>名称</th>
							<th>地址</th>
							<th>权限</th>
							<th>类型</th>
							<th>排序</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${menuList}" var="menu">
							<tr id="${menu.id}" pId="${menu.parentId}">
								<td>${menu.name}</td>
								<td>${menu.url}</td>
								<td>${menu.permission}</td>
								<td>${menu.type}</td>
								<td style="text-align: center;">${menu.sort}</td>
								<td nowrap><a
									href="${basePath}/sys/menu/toMenuEdit?editFlag=2&menuId=${menu.id}">修改</a>
									<a href="javascript:deptMgr.delMenu(${menu.id})">删除</a> <a
									href="${basePath}/sys/menu/toMenuEdit?editFlag=1&parentId=${menu.id}">添加下级菜单</a>
								</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<jsp:include page="../foot.jsp" />
</body>
</html>